<?php

/**
 * Encrypt / Decrypt a string
 */
class Mcrypt
{

    public static function encrypt($pure_string, $encryption_key)
    {
        return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, hash('sha256', $encryption_key, true), utf8_encode($pure_string), MCRYPT_MODE_ECB));
    }

    public static function decrypt($encrypted_string, $encryption_key)
    {
        return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, hash('sha256', $encryption_key, true), base64_decode($encrypted_string), MCRYPT_MODE_ECB), "\0");
    }

}
